﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Authorization.Application;
using Authorization.Entitys.DTO;
using Authorization.Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Vue.H5.Authorization.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly UserApps userApps;

        public UserController(UserApps _userApps)
        {
            userApps = _userApps;
        }

        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPut("updpswd/{userId}")]
        public async Task<NarutoResult> UpdatePassword(string userId, UpdatePasswordDTO info) => await userApps.UpdatePassword(userId, info);

        /// <summary>
        /// 注册
        /// </summary>
        /// <returns></returns>
        [HttpPost("register")]
        public async Task<NarutoResult> Register(RegisterDTO info) => await userApps.Register(info);
        /// <summary>
        /// 根据邮箱重置密码
        /// </summary>
        /// <returns></returns>
        [HttpPost("resetbyemail")]
        public async Task<NarutoResult> ResetPswdByEmail(ResetPswdByEmailDTO info) => await userApps.ResetPswdByEmail(info);
    }
}
